package com.shopping.userside.goods.service.impl;

import com.shopping.userside.goods.pojo.Goods;
import com.shopping.userside.goods.dao.GoodsDao;
import com.shopping.userside.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;

/**
 * (Goods)表服务实现类
 *
 * @author xusai
 * @since 2020-06-02 10:50:32
 */
@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsDao goodsDao;

    @Override
    public List<Goods> queryAll() {
        return  goodsDao.selectAll();
    }

    @Override
    public List<Goods> list(Map searchGoodsMap) {
        Example example = new Example(Goods.class);
        //封装查询条件
        Example.Criteria criteria = example.createCriteria();
        if (searchGoodsMap!=null && searchGoodsMap.size()>0){
            criteria.andLike("gName","%"+searchGoodsMap.get("gName")+"%");
        }
        List<Goods> goodsList = goodsDao.selectByExample(example);
        return goodsList;
    }

}